package org.garden.common;

import java.io.Serializable;

public class Result implements Serializable {

    private static final long serialVersionUID = -5499832476954209012L;

    private int status;

    private String msg;

    private Object data;

    private long timestamp;

    public static Result success() {
        return success(null);
    }

    public static Result success(Object data) {
        Result dto = new Result();
        dto.status = 200;
        dto.msg = "请求成功";
        dto.timestamp = System.currentTimeMillis();
        dto.data = data;
        return dto;
    }

    public static Result fail() {
        return fail("请求失败");
    }

    public static Result fail(String msg) {
        return fail(500, msg);
    }

    public static Result fail(int status, String msg) {
        Result result = new Result();
        result.status = status;
        result.msg = msg;
        result.timestamp = System.currentTimeMillis();
        return result;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
}
